package com.right.util;


/**********************************************
 * @author pillar
 * @date 2018/5/24
 **********************************************/
public final class StringUtil {

    /**
     * 按需十六进制转换
     * @param bytes
     * @param pos
     * @param len
     * @return
     */
    public static String toHexString(byte[] bytes, int pos, int len) {
        StringBuffer sb = new StringBuffer(len * 2);
        for(int i = pos; i < pos + len; ++i) {
            sb.append(convertDigit(bytes[i] >> 4));
            sb.append(convertDigit(bytes[i] & 15));
        }
        return sb.toString();
    }
    private static char convertDigit(int value) {
        value &= 15;
        return value >= 10?(char)(value - 10 + 97):(char)(value + 48);
    }

    /**
     * 是否为空
     * @param s
     * @return
     */
    public static boolean isEmpty(String s) {
        return null == s || "".equals(s);
    }
}
